<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:include page="${pageContext.request.contextPath}/include/pageTitleBread.jsp"/>
<div id="page-content">
    <div class="col-lg-12">
        <div class="panel">
            <div class="panel-heading">
                <h3 class="panel-title">${pageInfo.innerTitle}</h3>
            </div>
            <form id="sysConfigForm" class="panel-body form-horizontal form-padding">

                <div class="form-group">
                    <label class="col-sm-3 control-label">一级会员分润：</label>
                    <div class="col-sm-5">
                        <input id="flFirstProfit" name="flFirstProfit" class="form-control" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">二级会员分润：</label>
                    <div class="col-sm-5">
                        <input id="flSecondProfit" name="flSecondProfit" class="form-control" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">三级会员分润：</label>
                    <div class="col-sm-5">
                        <input id="flThirdProfit" name="flThirdProfit" class="form-control" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">分润类型：</label>
                    <div class="col-sm-5">
                        <input id="fl_type_ml" class="magic-radio" type="radio" name="flType"
                               value="0">
                        <label for="fl_type_ml">百分比</label>
                        <input id="fl_type_cd" class="magic-radio" type="radio" name="flType"
                               value="1" checked>
                        <label for="fl_type_cd">实际金额</label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">最低提现金额：</label>
                    <div class="col-sm-5">
                        <input id="flMinWithdraw" name="flMinWithdraw" class="form-control" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">分销资格最低购买金额：</label>
                    <div class="col-sm-5">
                        <input id="flMinBuy" name="flMinBuy" class="form-control" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">利润多少天可提现：</label>
                    <div class="col-sm-5">
                        <input id="flIncomeWithdrawDay" name="flIncomeWithdrawDay" class="form-control" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">所属客户：</label>
                    <div class="col-sm-5">
                        <select name="flCstId" id="flCstId" class="form-control">
                            <option value="-1">平台配置</option>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">是否启用分销模式：</label>
                    <div class="col-sm-5">
                        <input id="flIsEnableDisN" class="magic-radio" type="radio" name="flIsEnableDis"
                               value="0">
                        <label for="flIsEnableDisN">禁用</label>
                        <input id="flIsEnableDisY" class="magic-radio" type="radio" name="flIsEnableDis"
                               value="1" checked>
                        <label for="flIsEnableDisY">启用</label>
                    </div>
                </div>
                <div class="panel-footer">
                    <div class="row">
                        <div class="col-sm-9 col-sm-offset-3">
                            <button class="btn btn-warning" type="reset">重置</button>
                            <button class="btn btn-mint" type="submit">保存</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script>

    function save() {
        var data = common_ajax.ajaxFunc("/sysConfig/saveOrUpdate", $('#sysConfigForm').serialize(), "json", null);
        if (data.code === 0) {
            pointLion.alertMsg("保存成功!", "success", "small", function () {
                doPjax(ctx + '/sysConfig');//跳转到列表页
            });
        } else {
            pointLion.alertMsg("操作失败!", "danger", "small", function () {
                doPjax(ctx + '/sysConfig');//跳转到列表页
            });
        }
    }

    $(document).ready(function () {
        $('#sysConfigForm').bootstrapValidator({
            excluded: [":hidden"],//关键配置，表示只对于隐藏域不进行验证，其他的表单元素都要验证
            fields: {
                "fl_code": {
                    validators: {
                        notEmpty: {
                            message: '*XXXX不能为空!'
                        },
                        stringLength: {
                            min: 2,
                            message: '*XXXX必须大于两位'
                        }
                    }
                },
                "fl_name": {
                    validators: {
                        notEmpty: {
                            message: '*XXXX不能为空'
                        },
                        stringLength: {
                            min: 2,
                            message: '*XXXX必须大于两位'
                        }
                    }
                }
            }
        }).on("success.form.bv", function (e) {
            save();
            return false;//阻止表单跳转
        });
    });
</script>
